import { getAreaObj } from '@/utils/util'
import {configToSearch,toSearchHandle} from '@/views/datacenter/business/utils/index'

const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '所属地区',
			prop: 'belongAreaName',
			span: 6,
		},
		{
			label: '机构名称',
			prop: 'organizationName',
			type: 'input',
			span: 6,
		},
		// {
		// 	label: '统一社会信用代码',
		// 	prop: 'creditCode',
		// 	type: 'input',
		// 	span: 6,
		// },
		{
			label: '联系人',
			prop: 'dutyUser',
			type: 'input',
			span: 6,
		},
		{
			label: '联系方式',
			prop: 'dutyUserPhone',
			type: 'input',
			plusXing: '5,2',
			span: 6,
		},
		{
			label: '申请人数',
			prop: 'applyPeopleTotal',
			span: 6,
		},
		{
			label: '申请金额',
			prop: 'applySumAmount',
			type: 'input',
			span: 6,
		},
		{
			label: '申请时间',
			prop: 'applyTime',
			type: 'input',
			span: 6,
		},
		{
			label: '是否可信',
			prop: 'isBelievable',
			custome: 'tag',
			dicData: [
				{ label: '否', value: 0,type:'danger' },
				{ label: '是', value: 1,type:'success' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}
const moreSet:any = {
	column:[
		{
			label:"申请补贴金额（护理型）",
			prop:"applyNurseSubsidyAmount",
			append:"元",
			type:"input"
		},
		{
			label:"申请补贴金额（普通型）",
			prop:"applySubsidyAmount",
			append:"元",
			type:"input"
		},
		{
			label:"申请总金额",
			prop:"applySumAmount",
			append:"元",
			type:"input"
		},
		{
			label:'申请时间',
			prop:"applyTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"申请类型",
			prop:"applyType",
			propName:"applyTypeLabel",
			api:'getDictItemList',                   type:'remoteSelect',            
			code:'ORG_BED_SUBSIDY_APPLY_TYPE'
		},
		{
			label:"申请承办人姓名",
			prop:"applyUndertakerName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"区核定床位数",
			prop:"approvedBedTotal",
			append:"张",
			type:"text"
		},
		{
			label:"平均床位建筑面积",
			prop:"averageBedBuildingArea",
			append:"平方米",
			type:"text"
		},
		{
			label:"银行账号",
			prop:"bankAccount",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"开户银行",
			prop:"bankName",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"床位总数",
			prop:'bedTotal',
			append:'张',
			type:"text"
		},
		{
			label:"所属区划",
			prop:"belongArea",
			type:"AplidAreaSelect"
		},
		{
			label:"营业执照(民非)证号",
			prop:"businessLicense",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"护理员持证人数",
			prop:"caregiverCertifiedTotal",
			append:"人",
			type:"text"
		},
		{
			label:"护理员数",
			prop:"certifiedPersonnelTotal",
			append:"人",
			type:"text"
		},
		{
			label:"入住老人数",
			prop:"checkSumOldman",
			append:"人",
			type:"text"
		},
		{
			label:"区民政部门审核时间",
			prop:"civilAdministrationAuditTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"区民政部门检查人姓名",
			prop:"civilAdministrationExamineName"
		},
		{
			label:"区民政部门意见",
			prop:"civilAdministrationOpinion",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:"机构统一信用编码",
			prop:"creditCode",
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
		},
		{
			label:"申报床位数(改护理型床位补贴申请)",
			prop:"declareBedNumber",
			append:"张",
			type:"text"
		},
		// {
		// 	label:"医生人数",
		// 	prop:"doctorTotal",
		// 	append:"人",
		// 	type:"text"
		// },
		{
			label:"双人间数",
			prop:"doubleRoomTotal",
			append:"间",
			type:"text"
		},
		{
			label:"机构负责人姓名",
			prop:"dutyUser",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"机构负责人联系电话",
			prop:'dutyUserPhone',
			type: 'text',
			maxlength: '11',
			showWordLimit: true,
		},
		{
			label:"电子邮件",
			prop:"email",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"检查时间",
			prop:"examineTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'资金来源',
			prop:"fundingSource",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:"普通型床位补贴标准",
			prop:"generalBedSubsidy",
		},
		{
			label:"申报普通型床位数",
			prop:"generalBedTotal",
			append:"张",
			type:"text"
		},
		{
			label:'领取新增补贴床位数',
			prop:'getSubsidyBedTotal',
			append:"张",
			type:"text"
		},
		{
			label:'领取时间',
			prop:"getTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"投资总额",
			prop:"investmentAmount",
			append:"元",
			type:"text"
		},
		{
			label:'机构占地面积',
			prop:"landArea",
			append:"平方米",
			type:"text"
		},
		{
			label:"房屋租赁或使用合同或房产证明",
			prop:"leaseContract",
			type:"upload"
		},
		{
			label:'机构法人身份证号',
			prop:"legalPersonIdCard",
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
		},
		{
			label:'机构法人姓名',
			prop:"legalPersonName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"机构法人联系电话",
			prop:"legalPersonPhone",
			type: 'text',
			maxlength: '11',
			showWordLimit: true,
		},
		{
			label:'管理人员数量',
			prop:"managerialStaffTotal",
			append:'人',
			type:"input"
		},
		{
			label:'医疗资质',
			prop:"medicalQualification",
			type:"upload"
		},
		{
			label:'医技人数',
			prop:"medicalTechnicalStaffTotal",
			append:"人",
			type:"text"
		},
		{
			label:"多人间数",
			prop:"multiPersonRoomTotal",
			append:"间",
			type:"text"
		},
		{
			label:"申请时间(改护理型床位补贴申请)",
			prop:"nurseApplyTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"申请承办人姓名(改护理型床位补贴申请)",
			prop:"nurseApplyUndertakerName"
		},
		{
			label:'区民政部门审核时间(改护理型床位补贴申请)',
			prop:"nurseCivilAdministrationAuditTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'区民政部门意见(改护理型床位补贴申请)',
			prop:"nurseCivilAdministrationOpinion"
		},
		{
			label:'护士人数',
			prop:"nurseTotal",
			append:"人",
			type:"text"
		},
		{
			label:'区财政部门审核时间(改护理型床位补贴申请)',
			prop:"nurseTreasuryDeptAuditTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"区财政部门意见(改护理型床位补贴申请)",
			prop:"nurseTreasuryDeptOpinion"
		},
		// {
		// 	label:"护理型床位补贴标准",
		// 	prop:"nursingBedSubsidy",
		// 	type: 'text',
		// 	append:"元/张"
		// },
		// {
		// 	label:'申报护理型床位数',
		// 	prop:"nursingBedTotal",
		// 	append:"张",
		// 	type:"text"
		// },
		{
			label:"入住率",
			prop:"occupancyRate",
			append:'百分比',
			isNUm:true
		},
		{
			label:'护理型床位建设补贴领取金额(领取第一笔新增床位补贴基本情况)',
			prop:"oneNursingBedSubsidyAmount",
			append:"元",
			type:"text"
		},
		{
			label:'护理型床位建设补贴领取时间(领取第一笔新增床位补贴基本情况)',
			prop:"oneNursingSubsidyIssueTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'普通床位建设补贴领取金额(领取第一笔新增床位补贴基本情况)',
			prop:"oneOrdinaryBedSubsidyAmount",
			append:"元",
			type:"text"
		},
		{
			label:"普通床位建设补贴领取时间(领取第一笔新增床位补贴基本情况)",
			prop:"oneOrdinarySubsidyIssueTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"建筑工程消防验收合格意见书",
			prop:"opinionBook",
			type:"upload"
		},
		{
			label:'机构地址',
			prop:"organizationAddress",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:'养老机构设置相关证件',
			prop:"organizationCertificate",
			type:'upload'
		},
		{
			label:"机构设置证号(备案)",
			prop:"organizationFilings",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"机构名称",
			prop:"organizationName",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"机构类型",
			prop:"organizationType",
			propName:"organizationTypeLabel",
			api:"getDictItemList",
			type:"remoteSelect",
			code:"ORG_TYPE"
		},
		{
			label:"食品经营许可证",
			prop:"permit",
			type:"upload"
		},
		{
			label:'邮政编码',
			prop:"postalCode",
			type: 'text',
			maxlength: '6',
			showWordLimit: true,
		},
		{
			label:'五年不改变房屋使用用途承诺',
			prop:"promise",
			type:"upload"
		},
		{
			label:'产权性质',
			prop:"propertyType",
			propName:"propertyTypeLabel",
			code:"PROPERTY_TYPE",
			api:"getDictItemList",
			type:"remoteSelect"
		},
		{
			label:"入住老人与总床位的比例",
			prop:"ratio",
			idNum:true,
			append:'百分比'
		},
		{
			label:"堪察人姓名",
			prop:"reconnaissanceName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"堪察人意见",
			prop:"reconnaissanceOpinion",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:"堪察时间",
			prop:"reconnaissanceTime",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"民办非企业单位登记证书或工商营业执照",
			prop:"registerCertificate",
			type:"upload"
		},
		{
			label:'注册资金',
			prop:"registeredCapital",
			append:"元",
			type:"text"
		},
		{
			label:"备注",
			prop:"remark",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:'房间总数',
			prop:'roomTotal',
			append:'间',
			type:'text'
		},
		{
			label:'单人间数',
			prop:'singleRoomTotal',
			append:'间',
			type:'text'
		},
		// {
		// 	label:"补贴唯一值",
		// 	prop:"soleValue"
		// },
		{
			label:'员工总数',
			prop:"staffTotal",
			append:"人",
			type:"text"
		},
		{
			label:'补贴金额(改护理型床位补贴申请)',
			prop:"subsidyAmount",
			append:"元",
			type:"text"
		},
		{
			label:'补贴标准(改护理型床位补贴申请)',
			prop:"subsidyStandard",
		},
		{
			label:'总金额',
			prop:"totalAmount",
			append:"元",
			type:"text"
		},
		{
			label:'区财政部门审核时间',
			prop:"treasuryDeptAuditTime",
			type:'date',
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'区财政部门意见',
			prop:"treasuryDeptOpinion",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:'三人间数',
			prop:'tripleRoomTotal',
			type:"text",
			append:"间"
		},
		{
			label:'领取补贴金额（护理型）申请领取第二笔新增床位基本情况',
			prop:"twoApplyNurseSubsidyAmount",
			append:"元",
			type:"text"
		},
		{
			label:"领取补贴金额（普通型）申请领取第二笔新增床位基本情况",
			prop:"twoApplySubsidyAmount",
			append:"元",
			type:"text"
		},
		{
			label:'区民政部门审核时间(申请领取第二笔新增床位基本情况)',
			prop:"twoCivilAdministrationAuditTime",
			type:'date',
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'区民政部门意见(申请领取第二笔新增床位基本情况)',
			prop:"twoCivilAdministrationOpinion"
		},
		{
			label:'区财政部门审核时间(申请领取第二笔新增床位基本情况)',
			prop:"twoTreasuryDeptAuditTime",
			type:'date',
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'区财政部门意见(申请领取第二笔新增床位基本情况)',
			prop:"twoTreasuryDeptOpinion"
		},
		{
			label:'机构使用面积',
			prop:"usableArea",
			append:"平方米",
			type:"text"
		},
		{
			label:'工勤人数',
			prop:"utilityStaffTotal",
			append:"人",
			type:"text"
		}
	]
}
const moreSearchConfig:any = {
	inline: true,
	showBtn: false,
	labelPosition: 'left',
	column:[
		...configToSearch(moreSet.column)
	]
}
const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共5个：',
					children: [
						{
							label: '《机构养老床位建设补贴信息表》',
							link: true,
							url: 'dpOrgBedSubsidy_downloadTemplate',
						},

						{
							label: '《机构养老床位建设补贴-勘察项目》',
							link: true,
							url: 'view_dpOrgBedSubsidyReconnaissance_downloadTemplate',
						},
						{
							label: '《机构养老床位建设补贴房间》',
							link: true,
							url: 'view_dpOrgBedSubsidyRoom_downloadTemplate',
						},
						{
							label: '《机构养老床位建设补贴-老人花名册》',
							link: true,
							url: 'view_dpOrgBedSubsidyServiceObject_downloadTemplate',
						},
						{
							label: '《机构养老床位建设补贴-员工花名册》',
							link: true,
							url: 'view_dpOrgBedSubsidyStaff_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入《机构养老床位建设补贴信息表》',
			description: '',
			uploadTip: '机构养老床位建设补贴信息表',
			active: 2,
			url: 'dpOrgBedSubsidy_import',
			code: 2028,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的机构养老床位建设补贴信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《机构养老床位建设补贴-勘察项目信息表》',
			description: '',
			uploadTip: '机构养老床位建设补贴-勘察项目信息表',
			active: 3,
			url: 'view_dpOrgBedSubsidyReconnaissance_import',
			code: 2029,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的机构养老床位建设补贴-勘察项目信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《机构养老床位建设补贴房间信息表》',
			description: '',
			uploadTip: '机构养老床位建设补贴房间信息表',
			active: 4,
			url: 'view_dpOrgBedSubsidyRoom_import',
			code: 2030,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的机构养老床位建设补贴房间信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《机构养老床位建设补贴-老人花名册信息表》',
			description: '',
			uploadTip: '机构养老床位建设补贴-老人花名册信息表',
			active: 5,
			url: 'view_dpOrgBedSubsidyServiceObject_import',
			code: 2031,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的机构养老床位建设补贴-老人花名册信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《机构养老床位建设补贴-员工花名册信息表》',
			description: '',
			uploadTip: '机构养老床位建设补贴-员工花名册信息表',
			active: 5,
			url: 'view_dpOrgBedSubsidyStaff_import',
			code: 2032,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的机构养老床位建设补贴-员工花名册信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
	],
}
export const baseConfig: any = {
	pageName: '机构养老床位建设补贴',
	dictcodes: [],
	rowKey: 'id',
	tipLabel: 'organizationName',
	// exportMqTopic: '/ning/export',
	exportMqTopic: [
		{
			topic: '/ning/export/dpOrgBedSubsidy/',
			label: '机构养老床位建设补贴信息',
			code: 2028,
			po: 'dpOrgBedSubsidyPO',
		},
		{
			topic: '/ning/export/dpOrgBedSubsidyReconnaissance/',
			label: '机构养老床位建设补贴-勘察项目',
			code: 2029,
			po: 'dpOrgBedSubsidyReconnaissancePO',
		},
		{
			topic: '/ning/export/dpOrgBedSubsidyRoom/',
			label: '机构养老床位建设补贴房间',
			code: 2030,
			po: 'dpOrgBedSubsidyRoomPO',
		},
		{
			topic: '/ning/export/dpOrgBedSubsidyServiceObject/',
			label: '机构养老床位建设补贴-老人花名册',
			code: 2031,
			po: 'dpOrgBedSubsidyServiceObjectPO',
		},
		{
			topic: '/ning/export/dpOrgBedSubsidyStaff/',
			label: '字 机构养老床位建设补贴-员工花名册',
			code: 2032,
			po: 'dpOrgBedSubsidyStaffPO',
		},
	],
	api: {
		moreSearch:"view_dpOrgBedSubsidy_search",
		index: 'dpOrgBedSubsidy_page',
		delete: 'dpOrgBedSubsidy_del',
		export: 'view_dpOrgBedSubsidy_exportAll',
		import: 'dpOrgBedSubsidy_import',
	},
	auth: {
		index: 'view_dpOrgBedSubsidy_page',
		mulitSet: 'mulitSet',
		delete: 'view_dpOrgBedSubsidy_del',
		// export: 'view_dpOrgBedSubsidy_exportAll',
		// import: 'view_dpOrgBedSubsidy_import',
	},
	paramsObj: {
		code: 2028,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '查看详情',
			type: 'primary',
			operate: 'Detail',
			auth: '',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	moreSearchConfig,
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',

		column: [
			{
				label: '信用代码',
				prop: 'creditCode',
				type: 'input',
				span: 6,
			},
			{
				label: '机构名称',
				prop: 'organizationName',
				type: 'input',
				span: 6,
			},

			{
				label: '联系方式',
				prop: 'dutyUserPhone',
				type: 'input',
				span: 6,
			},
			{
				label: '所属地区',
				prop: '',
				propName: 'cr_areas_name',
				type: 'AplidAreaSelect',
				span: 6,
			},
			{
				label: '联系人',
				prop: 'dutyUser',
				span: 6,
			},
			{
				label: '申请年月',
				prop: 'applyTimeBetween',
				type: 'daterange',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 12,
			},
		],
	},
	beforeOnLoadFormate: async (params) => {
		params = toSearchHandle(moreSearchConfig,{},params)
		// if(params.applyTimeBetween){
		// 	params.applyTimeBetween = params.applyTimeBetween.join(',')
		// }else{
		// 	params.applyTimeBetween = undefined
		// }
		const crAreasName: any = getAreaObj(params.cr_areas_name, 'belong')
		return Promise.resolve({
			...params,
			...crAreasName,
			cr_areas_name: undefined, // 户籍区域
		})
	},
	onLoadFormate: async (arr) => {
		const tableData = arr.map((item) => {
			const cr_areas_name: any = getAreaObj(item, 'belong')
			return {
				...item,
				...cr_areas_name,
			}
		})
		console.log(tableData, 'tableData')
		return Promise.resolve(Object.freeze(tableData))
	},
	tableConfig,
	importConfig,
}

export const getDictLabel = (dictObj,code,value) =>{
	if(dictObj&&code&&value){
		let dictList = dictObj[code]
		let list =  dictList.find(el=>{
			return el.value = value
		})
		return list[0]
	}
}
